<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>beginBitmapFill</title>
	<script type="text/javascript" src="../../lufylegend-1.8.12.min.js"></script>
	</head>
	<body>
			<div id="legend"></div>
			<script>
				init(50,"legend",800,600,main);
				
				var vertices;
				var indices;
				var uvtData;
				var backLayer;
				var bitmapData,bitmapData2;
				var rows=20,cols=20;
				var mi=0;
				var imgData = [
					{name:"face",path:"face.jpg"}
				];
				var imglist;
				function main(){
					LLoadManage.load(imgData,null,gameInit);
				}
				function gameInit(result){
					imglist = result;
					bitmapData = new LBitmapData(imglist["face"]);
					bitmapData.lock();
					bitmapData2 = new LBitmapData(null,0,0,500,400,LBitmapData.DATA_CANVAS);
					var img = bitmapData.getPixels(new LRectangle(75,50,100,100));
					var rect = new LRectangle(50,100,100,100);
					var rect1 = new LRectangle(150,100,100,100);
					bitmapData2.lock();
					bitmapData2.setPixels(new LRectangle(50,30,50,50),img);
					bitmapData2.setPixels(new LRectangle(100,30,50,50),img);
					bitmapData2.setPixels(new LRectangle(150,30,50,50),img);
					bitmapData2.setPixels(new LRectangle(200,30,50,50),img);
					for(var y=0;y<rect.height;y++){
						for(var x=0;x<rect.width;x++){
							var i = y*4*100+x*4;
							bitmapData2.setPixel(rect.x+rect.width-x,y+rect.y,[img.data[i],img.data[i+1],img.data[i+2],img.data[i+3]]);
						}
					}
					for(var y=0;y<rect1.height;y++){
						for(var x=0;x<rect1.width;x++){
							var i = y*4*100+x*4;
							bitmapData2.setPixel(x+rect1.x,y+rect1.y,[img.data[i],img.data[i+1],img.data[i+2],img.data[i+3]]);
						}
					}
					bitmapData2.unlock();
					
					backLayer = new LSprite();
					addChild(backLayer);
					backLayer.addChild(new LBitmap(bitmapData2));
				}
			</script>
			
			
			
	</body>
</html>